/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package resoursePlan.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import resoursePlan.Person;
import resoursePlan.ResoursePlanPackage;
import resoursePlan.Role;
import resoursePlan.RoleAssignment;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Role Assignment</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link resoursePlan.impl.RoleAssignmentImpl#getRoleWorkloadRatio <em>Role Workload Ratio</em>}</li>
 *   <li>{@link resoursePlan.impl.RoleAssignmentImpl#getAssigned <em>Assigned</em>}</li>
 *   <li>{@link resoursePlan.impl.RoleAssignmentImpl#getRole <em>Role</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RoleAssignmentImpl extends EObjectImpl implements RoleAssignment {
	/**
	 * The default value of the '{@link #getRoleWorkloadRatio() <em>Role Workload Ratio</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoleWorkloadRatio()
	 * @generated
	 * @ordered
	 */
	protected static final int ROLE_WORKLOAD_RATIO_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getRoleWorkloadRatio() <em>Role Workload Ratio</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoleWorkloadRatio()
	 * @generated
	 * @ordered
	 */
	protected int roleWorkloadRatio = ROLE_WORKLOAD_RATIO_EDEFAULT;

	/**
	 * The cached value of the '{@link #getAssigned() <em>Assigned</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssigned()
	 * @generated
	 * @ordered
	 */
	protected Person assigned;

	/**
	 * The cached value of the '{@link #getRole() <em>Role</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRole()
	 * @generated
	 * @ordered
	 */
	protected Role role;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RoleAssignmentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ResoursePlanPackage.Literals.ROLE_ASSIGNMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getRoleWorkloadRatio() {
		return roleWorkloadRatio;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRoleWorkloadRatio(int newRoleWorkloadRatio) {
		int oldRoleWorkloadRatio = roleWorkloadRatio;
		roleWorkloadRatio = newRoleWorkloadRatio;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE_WORKLOAD_RATIO, oldRoleWorkloadRatio, roleWorkloadRatio));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Person getAssigned() {
		if (assigned != null && assigned.eIsProxy()) {
			InternalEObject oldAssigned = (InternalEObject)assigned;
			assigned = (Person)eResolveProxy(oldAssigned);
			if (assigned != oldAssigned) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ResoursePlanPackage.ROLE_ASSIGNMENT__ASSIGNED, oldAssigned, assigned));
			}
		}
		return assigned;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Person basicGetAssigned() {
		return assigned;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAssigned(Person newAssigned) {
		Person oldAssigned = assigned;
		assigned = newAssigned;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ResoursePlanPackage.ROLE_ASSIGNMENT__ASSIGNED, oldAssigned, assigned));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Role getRole() {
		if (role != null && role.eIsProxy()) {
			InternalEObject oldRole = (InternalEObject)role;
			role = (Role)eResolveProxy(oldRole);
			if (role != oldRole) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE, oldRole, role));
			}
		}
		return role;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Role basicGetRole() {
		return role;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRole(Role newRole) {
		Role oldRole = role;
		role = newRole;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE, oldRole, role));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE_WORKLOAD_RATIO:
				return getRoleWorkloadRatio();
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ASSIGNED:
				if (resolve) return getAssigned();
				return basicGetAssigned();
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE:
				if (resolve) return getRole();
				return basicGetRole();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE_WORKLOAD_RATIO:
				setRoleWorkloadRatio((Integer)newValue);
				return;
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ASSIGNED:
				setAssigned((Person)newValue);
				return;
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE:
				setRole((Role)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE_WORKLOAD_RATIO:
				setRoleWorkloadRatio(ROLE_WORKLOAD_RATIO_EDEFAULT);
				return;
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ASSIGNED:
				setAssigned((Person)null);
				return;
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE:
				setRole((Role)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE_WORKLOAD_RATIO:
				return roleWorkloadRatio != ROLE_WORKLOAD_RATIO_EDEFAULT;
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ASSIGNED:
				return assigned != null;
			case ResoursePlanPackage.ROLE_ASSIGNMENT__ROLE:
				return role != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (roleWorkloadRatio: ");
		result.append(roleWorkloadRatio);
		result.append(')');
		return result.toString();
	}

} //RoleAssignmentImpl
